
## README FOR:



Article title: Foreign Aid, FDI and the Personalization of Power in Autocracies             
Authors: Bernat Puertas (Universitat Pompeu Fabra) and Abel Escribà-Folch (Universitat Pompeu Fabra and Institut Barcelona d'Estudis Internacionals)                                      
Journal: PSRM - Political Science Research and Methods				                                               
Contact: bernat.puertas@upf.edu                                              




## Software:

Estimates and all tables and figures were done using R version 4.2.2 (2022-10-31 ucrt)
(Previous versions ran in older versions of R without difficulties.) 


## Computer Specification:

Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz 3.31 GHz
64 bits
16.0 GB (15.9 GB usable) RAM
Windows 10, Version 22H2


## R packages needed:

- tidyverse (version 2.0.0) --> Data manipulation
- countrycode (version 1.6.0) --> Adding COW codes
- readstata13 (version 0.10.1) --> Read .dta files
- DataCombine (version 0.2.21) --> Data manipulation and lags
- fixest (version 0.12.0) --> FE regression analysis
- estimatr (version 1.0.4) --> regression analysis. 
- modelsummary (version 1.4.5) --> regression results
- sandwich (version 3.1-0) --> SE robust to heteroskedasticity
- clubSandwich (version 0.5.11) --> Clustered SE 
- lmtest (version 0.9-40) --> robust SE
- mediation (version 4.5.0) --> mediation analysis
- patchwork (version 1.2.0) --> Combining plots
- tintytext (version 0.51 ) --> exporting tables
- pdftools (version 3.4.0) --> exporting tables

*Other packages and corresponding versions included in some of the packages (e.g. tidyverse) are not detalied.


## STATA packages needed: 

- asdoc package --> to export table A1


## Files:

The following files reproduce the data cleaning and analyses in the main paper and appendix, as well as the tables and figures.

- Replication code_PSRM_Aid_FDI_Personalism.R --> R file for data cleaning and analyses of the main paper and appendix.
- Cleaning.do --> .do file needed for adding missing COW country codes during cleaning. In file "Replication code.R" we specify when "Cleaning.do" is needed.
- Summary stats.do --> .do file to generate Table A1 (summary statistics). 


The file "Replication code_PSRM_Aid_FDI_Personalism.R" reproduces all the cleaning and analyses, as well as tables and figures, of the paper (except for Table A1).
The file "Cleaning.do" is used during the cleaning stage and we specify when to use it in file "Replication code_PSRM_Aid_FDI_Personalism.R"


## Other files:

- Replication code_PSRM_Aid_FDI_Personalism.RData --> RData file storing all objects produced during cleaning and analyses.
- PSRM_Aid_FDI_Personalism.log --> log file of "Replication code.R".
- PSRM_Aid_FDI_Personalism_Cleaning-stata.log --> log file of "Cleaning.do"
- PSRM_Aid_FDI_Personalism_SumStats-stata.log --> log file of "Summary stats.do"


## Data: 

Data files (after cleaning) to reproduce the analyses, figures and tables.

- "aid-fdi-personalism_NEW.csv" or
- "aid-fdi-personalism_NEW.dta" 


## Other data:

We also include other data files from other works. These are used during the cleaning. In the main text we include the references of each data source. 
The reader will notice that there may be three versions of each file in those cases in which adding the COW country codes was needed.
In these cases (specified in the "Replication code.R" file), the missing COW country codes are added in STATA using the "Cleaning.do" file and then loaded back to R. 

- AidData Project (Tierney et al. 2011) --> files "AidData Project_raw.csv: ; "AidData Project_noCOW.csv" and "AidData Project_COW.csv". Data on foreign aid.
- GWF personalism data (Geddes, Wright and Frantz 2018) --> file "GWF_personalism_raw.csv". Data on personalism and autocratic regimes.
- GWF data (Geddes, Wright and Frantz 2014) --> file "GWF_raw.dta". Data on autocratic regimes.
- Data on military spending (Singer, Bremer and Stuckey 1972) --> file "chin et al 2021.dta" (Chin et al 2022, CPS, Replication materials). 
- EPR data (Wimmer, Cederman and Min 2009) --> file EPR_raw
- Security and party personalism (Chin, Song and Wright 2023, BJPolS) --> file "Party and security personalism.dta".  We replicate their .do file in order to get the indexes.
- Oil per capita (Ross and Mahdavi 2015) --> files "Ross_raw.csv"; "Ross_noCOW.csv" and "Ross_COW.csv". Data on oli resources per capita.
- World Development Indicators (World Bank 2023) --> files "WDI_raw (Metadata).csv"; "WDI_raw.csv"; "WDI_noCOW.csv" and "WDI_COW.csv". Data on foreign aid and FDI (among others). 


## Tables:

All tables can be generated using the file "Replication code_PSRM_Aid_FDI_Personalism.R", except for Table A1 that is generated with the file "Summary stats.do". 

We generate the LaTeX tables using the RFunction etable() from the RPackage fixest. 
As we specify in the file "Replication code_PSRM_Aid_FDI_Personalism.R", we later edit the output produced by etable() in LaTeX for aesthetic reasons.
We also specify that the this function might change the sign of the coefficients when they are smaller that -0.0004 (aprox).

Main article: 

- Table 1.png
- Table 2.png
- Table 3.png
- Table 4.png
- Table 5.png

Online Appendix:

- Table A1.doc
- Table A2.png
- Table A3.png
- Table A4.png
- Table A5.png
- Table A6.png
- Table A7.png
- Table A8.html
- Table A9.html
- Table A10.png
- Table A11.png
- Table A12.png
- Table A13.png
- Table A14.png


## Figures:

Figures in the appendix in PDF format. 
The code to generate the figures is in file "Replication code_PSRM_Aid_FDI_Personalism.R" 

- Figure A1.pdf
- Figure A2_a.pdf
- Figure A2_b.pdf
- Figure A3.pdf
- Figure_A4.pdf
- Figure A5.pdf
- Figure_A6.pdf








